Structured Text Control Statements execute other statements based on certain condition. Statements include If statements, WHILE Statement, REPEAT Statement, FOR Statement, CASE Statement, EXIT Statement, RETURN Statement and Nested FB call. in industrial automation control statements help to create program that can adapt to changing conditions and respond to user input. Control statements change the flow of execution of statements. control statements help for making a certain decision based process and perform various tasks repeatedly, or switch to any process.
IF statements execute code if the condition is true other wise else condition execute. You can also define a condition without else statements. expression for if statements as below
a while loop execute statement repeatedly as long as a expression is true, execution of statement list continue until the expression condition is true. in a while loop result of an expression is a Boolean value which is either true or false. When the while loop expression is true than statement is executed Once the statement inside the while block is executed, the condition of expression again evaluated, and again if the expression condition is true then statement executed and again expression check, This process continues until the condition becomes False, at which point the execution of the while statement stops and the program continues with the next line of code.
above is the example of OMRON CX-Programmer Structured Text WHILE DO Statement. The WHILE expression must evaluate to a Boolean value. The statement-list is a list of several simple statements. The WHILE keyword repeatedly executes the statement-list while the expression is true. When the expression becomes false control passes to the next statement after the END_WHI
In Programming For_Do Loop Is A Conditional Statement Used To Repeatedly Execute A Block Of Code For A Specific Number Of Times Or Until A Certain Condition Is Met. It Is Used In Array, UDT Etc. For_Do Loop Not Used To Many Time In A Single Scan Because It Causes Controller Watchdog To Timeout And Causes A Major Fault And Controller Does Not Execute Other Statements In The Routine Until It Completes The Loop.Syntax For For_Do Loop Is Below
CASE OF Is a Control Flow Statement That Used for Execute Different Statement list Of Code Based on the Value of the Selector or Expression. CASE OF Is An Alternative Of Multiple If-Else-If Statements. CASE OF Easy To Understand. Basic Syntax Of CASE OF Statement Is A Selector Or Expression To Be Evaluated Based On Result Label Select. In Structured Text Language, CASE OF Is A Variable Selector Or Selection Statement That Allows A Program To Choose Among Multiple Alternatives Based On The Value Of A Variable. Use CASE_OF To Select What To Do Based On A Numerical Value. Syntax for
CASE_OF Is Control Flow Statement Which Match Selector Value With Numeric_expression If Numeric_expression And Selector Value Matched Than Statement Of Select Selector Value Is Executed Otherwise Else Statement Executed. Following Is Representation Of Working Case_Of Statement.
The REPEAT statement repeat a statement-list a certain number of times or until a certain condition is met. The REPEAT Statement repeatedly executes the statement-list while the expression is false. When the expression becomes true control passes to the next statement after END_REPEAT. syntax for REPEAT statement is